package it.ricettario;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class ImageFrame extends JScrollPane {
	public ImageFrame() {
	}

	BufferedImage image;
	int height = 0;
	int width = 0;
	
	@Override
	protected void paintComponent(Graphics g) {
		g.create();
		g.drawImage(image, 0, 0, width, height, null);
	}
	
	public void read(String imagePath1) {
		String imagePath = "C:\\Progetti\\Ricettario\\workspace\\Ricettario\\Ricette\\1 - ANTIPASTI\\focaccette con olive.jpg";
		try {
			File input = new File(imagePath);		
			image = ImageIO.read(input);
		} catch (IOException ie) {
			System.out.println("Error:" + ie.getMessage());
		}
	}

	public static void main(String args[]) throws Exception {
		JFrame frame = new JFrame();
		JScrollPane frameImage = new ImageFrame();
		frameImage.setVisible(true);
		String imagePath = "C:\\Progetti\\Ricettario\\workspace\\Ricettario\\Ricette\\1 - ANTIPASTI\\focaccette con olive.jpg";
		frame.getContentPane().add(frameImage);
		frame.setSize(500, 500);
		frame.setVisible(true);
		
	}
}
